import BasicConfig from "../utils/config";

/**
 * 订单查询入参
 * 1.待支付
 * 2.待服务
 * 3.待确认
 * 4.待评价
 * 5.售后
 * 6.待预约
 */
export const searchOrderStatus = {
  awaitPay: 1,
  awaitService: 2,
  awaitConfirm: 3,
  awaitComment: 4,
  afterSales: 5,
  awaitReservation: 6,
};
/**
 * 订单状态
 * 0.已取消【重新下单】
 * 1.待付款【取消订单&支付】
 * 1.1 待预约
 * 2.匹配中
 * 3.待服务
 * 4.服务中
 * 5.待确认
 * 6.待评价
 * 7.已完成
 * 8.已关闭
 */
export const orderStatus = {
  cancel: 0,
  awaitPay: 1,
  awaitReservation: 1.1,
  finding: 2,
  awaitService: 3,
  serving: 4,
  awaitConfirm: 5,
  awaitComment: 6,
  final: 7,
  close: 8,
};

const _dfStyle = {
  "border-radius": "15rpx",
  padding: "6rpx 20rpx",
  "font-size": "28rpx",
  "white-space": "nowrap",
};

const _dfBtnStyle = {
  "border-radius": "100rpx",
  padding: "14rpx 0rpx",
  "min-width": "200rpx",
  "text-align": "center",
  "font-size": "34rpx",
  "white-space": "nowrap",
};

/**
 * 订单操作key
 */
export const orderActionEnum = {
  cancel: "cancel",
  reset: "reset",
  pay: "pay",
  comment: "comment",
  again: "again",
  custom: "custom",
  /** 预约 */
  reservation: "reservation",
  /** 申请退款 */
  refund: "refund",
};

export const customBtn = {
  key: orderActionEnum.custom,
  label: "客服热线",
  value: orderStatus.custom,
  style: {
    color: BasicConfig.MainColor,
    border: `1px solid ${BasicConfig.MainColor}`,
    ..._dfBtnStyle,
  },
};

export const orderStatusConfig = {
  [orderStatus.cancel]: {
    value: orderStatus.cancel,
    label: "已取消",
    pagePath: null,
    style: {
      color: "#666666",
    },
    getBtns: () => {
      const btns = [
        {
          key: orderActionEnum.reset,
          label: "重新下单",
          value: orderStatus.cancel,
          style: {
            color: "#333333",
            border: "1px solid #CCCCCC",
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [orderStatus.awaitPay]: {
    value: orderStatus.awaitPay,
    label: "待支付",
    pagePath: "package-service/pages/order/detail",
    style: {
      color: "#208CEF",
    },
    getBtns: () => {
      const btns = [
        // {
        //   key: orderActionEnum.cancel,
        //   label: "取消订单",
        //   value: orderStatus.cancel,
        //   style: {
        //     color: "#333333",
        //     border: "1px solid #CCCCCC",
        //     ..._dfBtnStyle,
        //   },
        // },
        {
          key: orderActionEnum.pay,
          label: "支付",
          value: null,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [orderStatus.awaitReservation]: {
    value: orderStatus.awaitReservation,
    label: "待预约",
    actionLabel: "去预约",
    pagePath: "package-service/pages/order/details/awaitReservation",
    style: {
      color: "#208CEF",
    },
    getBtns: (status, firstAfterSaleStatus) => {
      const btns = [
        // {
        //   key: orderActionEnum.refund,
        //   label: "申请退款",
        //   value: null,
        //   style: {
        //     color: "#333333",
        //     border: "1px solid #CCCCCC",
        //     ..._dfBtnStyle,
        //   },
        // },
        {
          key: orderActionEnum.reservation,
          label: "预约",
          value: null,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [orderStatus.finding]: {
    value: orderStatus.finding,
    label: "匹配中",
    pagePath: "package-service/pages/order/details/finding",
    style: {
      color: "#F17922",
    },
    getBtns: () => {
      const btns = [];
      return btns;
    },
  },
  [orderStatus.awaitService]: {
    value: orderStatus.awaitService,
    label: "待服务",
    pagePath: "package-service/pages/order/details/awaitService",
    style: {
      color: "#208CEF",
    },
    getBtns: () => {
      return [];
    },
  },
  [orderStatus.serving]: {
    value: orderStatus.serving,
    label: "服务中",
    pagePath: "package-service/pages/order/details/serving",
    style: {
      color: "#F17922",
    },
    getBtns: () => {
      const btns = [];
      return btns;
    },
  },
  [orderStatus.awaitConfirm]: {
    value: orderStatus.awaitConfirm,
    label: "待确认",
    pagePath: "package-service/pages/order/details/awaitConfirm",
    style: {
      color: "#5449D0",
    },
    getBtns: () => {
      return [];
    },
  },
  [orderStatus.awaitComment]: {
    value: orderStatus.awaitComment,
    label: "已完成",
    desc: "待评价",
    pagePath: "package-service/pages/order/details/awaitComment",
    style: {
      color: "#00B07B",
    },
    getBtns: (status) => {
      const btns = [
        // {
        //   key: orderActionEnum.comment,
        //   label: "立即评价",
        //   value: null,
        //   style: {
        //     color: "#333333",
        //     border: "1px solid #CCCCCC",
        //     ..._dfBtnStyle,
        //   },
        // },
        {
          key: orderActionEnum.again,
          label: "再来一单",
          value: null,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [orderStatus.final]: {
    value: orderStatus.final,
    label: "已完成",
    pagePath: "package-service/pages/order/details/final",
    style: {
      color: "#00B07B",
    },
    getBtns: (status) => {
      // const btn = {
      //   key: orderActionEnum.comment,
      //   label: "立即评价",
      //   value: null,
      //   style: {
      //     color: "#333333",
      //     border: "1px solid #CCCCCC",
      //     ..._dfBtnStyle,
      //   },
      // };
      const btns = [
        {
          key: orderActionEnum.again,
          label: "再来一单",
          value: null,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      // if ([orderStatus.awaitComment, orderStatus.final].includes(status)) {
      //   btns.unshift(btn);
      // }
      return btns;
    },
  },
  [orderStatus.close]: {
    value: orderStatus.close,
    label: "已关闭",
    pagePath: null,
    style: {
      color: "#666666",
    },
    getBtns: (status) => {
      const btns = [
        // {
        //   key: orderActionEnum.again,
        //   label: "再来一单",
        //   value: null,
        //   style: {
        //     color: "#ffffff",
        //     background: BasicConfig.MainColor,
        //     ..._dfBtnStyle,
        //   },
        // },
      ];
      return btns;
    },
  },
};

/**
 * 订单二次上门状态
 * 0.已取消
 * 1.待付款[需要显示操作是否同意上门&firstStatus=5]
 * 2.匹配中
 * 3.待服务
 * 4.服务中
 * 5.待确认
 * 6.待评价
 * 7.已完成
 * 8.已关闭
 */
export const orderSecondStatus = {
  cancel: 0,
  awaitPay: 1,
  finding: 2,
  awaitService: 3,
  serving: 4,
  awaitConfirm: 5,
  awaitComment: 6,
  final: 7,
  close: 8,
};

/**
 * 支付模式
 * 0.微信
 * 1.支付宝
 * 2.银联
 */
export const payType = {
  wechat: 0,
  ali: 1,
  union: 2,
};

/**
 * 订单退款状态
 * 0.可申请退款
 * 1.待审核
 * 2.通过
 * 3.拒绝
 * 抖音pay-button-sdk order-status 1：申请退款,2：退款中,3：退款成功 ,4：退款失败
 */
export const orderRefundStatus = {
  can: 0,
  await: 1,
  success: 2,
  refuse: 3,
};
/**
 * 抖音订单退款状态(pay-button-sdk order-status)
 * 1.申请退款
 * 2.退款中
 * 3.退款成功
 * 4.退款失败
 */
export const dyRefundStatus = {
  can: 1,
  await: 2,
  success: 3,
  refuse: 4,
};
export const orderRefundStatusConfig = {
  [orderRefundStatus.can]: {
    value: orderRefundStatus.can,
    dyValue: dyRefundStatus.can,
    label: "可申请",
    style: {
      color: "#111111",
    },
  },
  [orderRefundStatus.await]: {
    value: orderRefundStatus.await,
    dyValue: dyRefundStatus.await,
    label: "退款中",
    style: {
      color: "#111111",
    },
  },
  [orderRefundStatus.success]: {
    value: orderRefundStatus.success,
    dyValue: dyRefundStatus.success,
    label: "已退款",
    style: {
      color: "#111111",
    },
  },
  [orderRefundStatus.refuse]: {
    value: orderRefundStatus.refuse,
    dyValue: dyRefundStatus.refuse,
    label: "退款失败",
    style: {
      color: "#111111",
    },
  },
};

/**
 * 订单退款模式(渠道)
 * 0.微信
 * 1.支付宝
 * 2.银联
 * 3.余额
 * 4.抖音支付
 */
export const orderRefundWay = {
  wechat: 0,
  alipay: 1,
  unionpay: 2,
  balance: 3,
  douyin: 4,
};
export const orderRefundWayConfig = {
  [orderRefundWay.wechat]: {
    value: orderRefundWay.wechat,
    label: "微信",
    style: {
      color: "#111111",
    },
  },
  [orderRefundWay.alipay]: {
    value: orderRefundWay.alipay,
    label: "支付宝",
    style: {
      color: "#111111",
    },
  },
  [orderRefundWay.unionpay]: {
    value: orderRefundWay.unionpay,
    label: "银联",
    style: {
      color: "#111111",
    },
  },
  [orderRefundWay.balance]: {
    value: orderRefundWay.balance,
    label: "余额",
    style: {
      color: "#111111",
    },
  },
  [orderRefundWay.douyin]: {
    value: orderRefundWay.douyin,
    label: "抖音支付",
    style: {
      color: "#111111",
    },
  },
};

/**
 * 酒店/日常订单售后状态
 * 0.正常
 * 1.部分售后中
 * 2.全部售后中
 * 3.部分已售后
 * 4.全部已售后
 */
export const hotelOrderAfterSaleStatus = {
  /** 正常 */
  normal: 0,
  /** 部分售后中 */
  parting: 1,
  /** 全部售后中 */
  alling: 2,
  /** 部分已售后 */
  partEnd: 3,
  /** 全部已售后 */
  allEnd: 4,
};

export const hotelOrderAfterSaleStatusConfig = {
  [hotelOrderAfterSaleStatus.normal]: {
    value: hotelOrderAfterSaleStatus.normal,
    label: "正常",
    style: {
      color: "#00B07B",
    },
  },
  [hotelOrderAfterSaleStatus.parting]: {
    value: hotelOrderAfterSaleStatus.parting,
    label: "部分售后中",
    orderLabel: "部分售后中",
    style: {
      color: "#F17922",
    },
  },
  [hotelOrderAfterSaleStatus.alling]: {
    value: hotelOrderAfterSaleStatus.alling,
    label: "全部售后中",
    orderLabel: "退款中",
    style: {
      color: "#F17922",
    },
  },
  [hotelOrderAfterSaleStatus.partEnd]: {
    value: hotelOrderAfterSaleStatus.partEnd,
    label: "部分已售后",
    orderLabel: "部分已售后",
    style: {
      color: "#f53a3a",
    },
  },
  [hotelOrderAfterSaleStatus.allEnd]: {
    value: hotelOrderAfterSaleStatus.allEnd,
    label: "全部已售后",
    orderLabel: "已退款",
    style: {
      color: "#f53a3a",
    },
  },
};

/**
 * 订单来源
 * 1.用户端日常服务
 * 2.酒店服务
 * 3.二次上门
 * 5.用户加急订单
 * 6.酒店订单加急
 * 7.保姆
 * 8.续时
 * 9.次卡
 */
export const orderSourceType = {
  /** 用户端日常服务 */
  daily: 1,
  /** 酒店服务 */
  hotel: 2,
  /** 二次上门 */
  second: 3,
  /** 用户加急订单 */
  urgent: 5,
  /** 酒店订单加急 */
  hotelUrgent: 6,
  /** 保姆 */
  nanny: 7,
  /** 续时 */
  append: 8,
  /** 次卡 */
  frequencyCard: 9,
};

/**
 * 订单类型
 * 1.服务订单(日常常规服务订单)
 * 2.酒店订单
 */
export const orderType = {
  /** 服务订单(日常常规服务订单) */
  service: 1,
  /** 酒店订单 */
  hotel: 2,
};

/**
 * 是否申请过售后
 * 1.申请过
 * 2.未申请过
 */
export const afterSalesApplyStatus = {
  /** 申请过 */
  done: 1,
  /** 未申请过 */
  not: 0,
};
